/**
 * 
 */
package com.eagle.coders.mybatis.generator;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import org.mybatis.generator.config.Configuration;
import org.mybatis.generator.api.MyBatisGenerator;
import org.mybatis.generator.config.xml.ConfigurationParser;
import org.mybatis.generator.internal.DefaultShellCallback;

/**
 * @author Anees
 * 
 */
public class Generator {

	public static void generate() {
		try {

			List<String> warnings = new ArrayList<String>();
			boolean overwrite = true;
			String genFile = 
				Generator.class.getClassLoader().getResource("com/eagle/coders/mybatis/generator/mybatic-generator.xml").getFile();
			
			System.out.println(" The File is :: "+ genFile);
			File configFile = new File(genFile);
			ConfigurationParser cp = new ConfigurationParser(warnings);
			Configuration configuration = cp.parseConfiguration(configFile);

			DefaultShellCallback callback = new DefaultShellCallback(overwrite);
			MyBatisGenerator myBatisGenerator = new MyBatisGenerator(configuration,
					callback, warnings);
			myBatisGenerator.generate(null);
		} catch (Exception e) {
			e.printStackTrace();
		}
		// MyBatisGenerator gen = new MyBatisGenerator();
	}
	
	public static void main(String [] args){
			
		generate();
	}
}
